package com.wys.initializer;

import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.annotation.Order;
import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.MutablePropertySources;

import java.util.HashMap;
import java.util.Map;

@Order(2)
public class SecondInitializer implements ApplicationContextInitializer {
	@Override
	public void initialize(ConfigurableApplicationContext applicationContext) {
		MutablePropertySources propertySources = applicationContext.getEnvironment().getPropertySources();
		Map<String,Object> map = new HashMap<>();
		map.put("key2","value2");
		MapPropertySource propertySource = new MapPropertySource("second",map);
		propertySources.addLast(propertySource);
		System.out.println("second initializer");
	}
}
